//
// Created by wdq on 22-9-18.
//
#include <iostream>

using namespace std;


void selectSort(int nums[], int length) {
    for (int i = 0; i < length - 1; i++) {
        int minIndex = i;
        for (int j = i + 1; j < length; j++) {
            if (nums[minIndex] > nums[j]) {
                minIndex = j;
            }
        }
        swap(nums[i], nums[minIndex]);
    }
}

int main() {

    int nums[] = {2, 6, 1, 56, 25, 67, 89, 5, 3, 3};
    printf("nums: ");
    for (auto &i: nums) {
        printf("%-4d ", i);
    }
    printf("\n");
    selectSort(nums, sizeof(nums) / sizeof(int));
    printf("sorting..........................\n");
    printf("nums: ");
    for (auto &i: nums) {
        printf("%-4d ", i);
    }
    printf("\n");
    return 0;
}